
import duckdb
DB_HOST = "1.15.241.228"
DB_USERNAME = "postgres"
DB_PASSWORD = "qiuwen123456"
DB_PORT = 5433
DB_NAME = "postgres"

PARAMETERS = f"host={DB_HOST} user={DB_USERNAME} password={DB_PASSWORD} port={DB_PORT} dbname={DB_NAME}"
ATTACH_QUERY = f"ATTACH '{PARAMETERS}' AS postgres_db  (TYPE POSTGRES);"
USE_QUERY = "USE postgres_db;"

with duckdb.connect() as conn:
    conn.install_extension("postgres")
    conn.load_extension("postgres")
    conn.sql(ATTACH_QUERY)
    conn.sql(USE_QUERY)
    conn.sql("SHOW TABLES").show()
    for i in range(1,100):
       conn.sql("INSERT INTO tbl VALUES ({i}, 'DuckDB42');".format(i=i))





